﻿<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Dreamer CMS - 后台管理系统</title> 
    <link href="/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="/css/style.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" media="all" href="/js/plugins/treeSelect/css/treeSelect.css"/>
	<link rel="stylesheet" type="text/css" href="/js/plugins/ztree-v3/css/bootstrapZTreeStyle.css"/>
</head>

<body>
<div class="row">
    <div class="col-md-12">
    	<h1 class="panel-heading">添加权限</h1>
        <!--breadcrumbs start -->
        <ul class="breadcrumb">
			<li><a href="/admin/dashboard/toIndex"><i class="fa fa-home"></i> 首页</a></li>
			<li class="active">添加权限</li>
		</ul>
        <!--breadcrumbs end -->
    </div>
</div>
<section class="panel">
	<div class="panel-body">
		<form class="col s12" id="form1" th:action="@{/admin/permission/add}" onsubmit="return validateForm();" method="post">
			<div class="form-group form-control-medium">
				<label for="permissionName">权限名称：</label>
				<input id="permissionName" name="permissionName" type="text" class="form-control" placeholder="权限名称" />
			</div>
			<div class="form-group form-control-medium">
				<label for="permissionCode">权限编码：</label>
				<input id="permissionCode" name="permissionCode" type="text" class="form-control" placeholder="权限编码" />
			</div>
			<div class="form-group form-control-medium">
				<label for="permissionUrl">权限路径：</label>
				<input id="permissionUrl" name="permissionUrl" type="text" class="form-control" placeholder="权限路径" />
			</div>
			<div class="form-group form-control-medium">
				<label for="parentId">所属菜单：</label>
				<div style="width: 100%;" class="treeSelect form-group form-control-medium"></div>
			</div>
			<div class="form-group form-control-medium">
				<label for="remark">备注：</label>
				<textarea rows="5" name="remark" class="form-control" placeholder="备注"></textarea>
			</div>
			<div class="form-btn-group-left" shiro:hasAnyPermissions="system:permission:toadd,system:permission:add">
            	<button type="submit" class="btn btn-info">保存</button>
            </div>
		</form>
	</div>
</section>
<script src="/js/jquery.min.js"></script>
<script src="/js/plugins/treeSelect/jquery.ztree.all.min.js"></script>
<script src="/js/plugins/treeSelect/treeSelect.js"></script>
<script src="/js/coco-message/coco-message.js"></script>
<script th:inline="javascript">
	var allList = [[${menuList}]];

	$(function () {
		$(".treeSelect").treeSelect({
	    	data: allList,
	        inputId: "menuId",
	        name: "menuId"
	    })
	});
   
	/* 保存方法 */
    function validateForm(){
    	var permissionName = $("#permissionName").val();
    	var permissionUrl = $("#permissionUrl").val();
    	var permissionCode = $("#permissionCode").val();
    	if(permissionName == null || permissionName==''){
			cocoMessage.error("权限名称不能为空");
    		return false;
    	}
    	if(permissionUrl == null || permissionUrl==''){
			cocoMessage.error("权限URL不能为空");
    		return false;
    	}
    	if(permissionCode == null || permissionCode==''){
    		cocoMessage.error("权限编码不能为空");
    		return false;
    	}
    	return true;
    }
</script>
</body>
</html>
